package org.nmgyjt.springboot.utils;

import lombok.extern.slf4j.Slf4j;
import org.nmgyjt.springboot.entity.exception.BizException;
import org.springframework.stereotype.Component;

import java.io.*;
import java.util.Properties;

@Slf4j
@Component
public class PropertiesUtil {


    private static Properties prop = new Properties();

    public String propLoad(String key) {

        InputStreamReader inputStream = null;
        try {
            File file = new File("/usr/local/cs_info_maintence/application.properties");
            FileInputStream fileInputStream = new FileInputStream(file);
            Properties properties = new Properties();
            BufferedReader bf = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8"));
            properties.load(bf);
            String property = properties.getProperty(key);
            log.info("短信发送模板内容:" + property);
            return property;

        } catch (FileNotFoundException e) {
            log.error(e.getMessage());
            throw new BizException(e.getMessage());
        } catch (IOException e) {
            log.error(e.getMessage());
            throw new BizException(e.getMessage());
        }
    }
}